﻿$(function () {
    $(document).click(function (event) {
        event = event || window.event;
        var target = event.target || event.srcElement;
        if (!target || !target.attributes ||
                !target.getAttribute('key')) {
            return;
        }
        var action = target.getAttribute('key');
        switch (action) {
            //删除菜单                                                                                                         
            case "module_menu_delete":
                Manage_Module.batchDelete(target);
                break;
            //删除导航                                                                                                          
            case "module_nav_delete":
                var jq = $("#tabs_module ul li.selected a span");
                var id = jq.attr("moduleid");
                var name = jq.text();
                Manage_Module.NavDelete(id, name);
                break;
            //点击tabs导航                                                                                                           
            case "module_tabs_click":
                var jq = $(target);
                $("#module_nav input[name='name']").val(jq.text());
                $("#module_nav input[name='sort_order']").val(jq.attr("sort"));
                break;
            //快速保存（导航）                    
            case "module_nav_fastsave":
                var jq = $("#tabs_module ul li.selected a span");
                var id = jq.attr("moduleid");
                Manage_Module.fastSave(id);
                break;
            //添加导航                     
            case "module_nav_add":
                var jq = $(target);
                var title = jq.text();
                var url = System_Path + "manage/module/MenuAdd";
                Manage_Module.openDialog(url, title, "", 0);
                break;
            //编辑导航                    
            case "module_nav_edit":
                var jq = $(target);
                var title = jq.text();
                var url = System_Path + "manage/module/MenuAdd";
                var id = $("#tabs_module ul li.selected a span").attr("moduleid");
                Manage_Module.openDialog(url, title, id, 0);
                break;
            //添加菜单                   
            case "module_menu_add":
                var jq = $(target);
                var title = jq.text();
                var url = System_Path + "manage/module/MenuAdd";
                var parentid = $("#tabs_module ul li.selected a span").attr("moduleid");
                Manage_Module.openDialog(url, title, "", parentid);
                break;
        }
    });

});